#import "RNEditItemBackgroundRoundedTop.h"
#import "RNConstants.h"

@implementation RNEditItemBackgroundRoundedTop

-(void)drawRect:(NSRect)frame {
    frame = [self bounds];

    CGFloat frameWidth = NSWidth(frame);
    CGFloat frameHeight = NSHeight(frame);
    NSBezierPath *path = [NSBezierPath bezierPath];
    
    [path moveToPoint:frame.origin];
    [path lineToPoint:NSMakePoint(frame.origin.x, frameHeight - RNDetailViewCellCornerRadius)];
    [path appendBezierPathWithArcFromPoint:NSMakePoint(frame.origin.x, frameHeight) toPoint:NSMakePoint(RNDetailViewCellCornerRadius, frameHeight) radius:RNDetailViewCellCornerRadius];
    [path lineToPoint:NSMakePoint(frameWidth - RNDetailViewCellCornerRadius, frameHeight)];
    [path appendBezierPathWithArcFromPoint:NSMakePoint(frameWidth, frameHeight) toPoint:NSMakePoint(frameWidth, frameHeight - RNDetailViewCellCornerRadius) radius:RNDetailViewCellCornerRadius];
    [path lineToPoint:NSMakePoint(frameWidth, frame.origin.y)];
    [path closePath];

    [[self backgroundColor] setFill];
    [path fill];
    
    [[self separatorColor] setStroke];
    [NSBezierPath strokeLineFromPoint:NSMakePoint(frame.origin.x, frame.origin.y) toPoint:NSMakePoint(frameWidth, frame.origin.y)];
}

@end
